const BaseHandler     = require('../base-handler');
const SystemServices  = require('../../../constants').SystemServices;
const HTTP_VERBS      = require('../../../constants').HTTP_VERBS;
const utils           = require('../../../utils');

class CollectHandler extends BaseHandler {
    get pattern() {
        return "/lb/:user_id.js";
    }

    doGET(request, response) {
        var userId = request.params.user_id;
        var env =process.env.NODE_ENV;
        this.Controller.getLeadFlowSettingsByUserId(userId, (result) => {
            response.setHeader('Content-type', 'application/javascript');
            response.render("sdk/entry-point", {
                leadflows: result,
                host: request.headers['host'],
                env:env
            });
        });
    }

    setup() {
        this.registerVerb(HTTP_VERBS.GET, this.doGET);
    }
}

module.exports = CollectHandler;